<?php /* !!!ATTENTION!!! PLEASE DO NOT MODIFY THE FILE! 
Copy it preserving its path from the var/ait_path folder to the
app folder. i.e. in var/ait_path folder the file is located in folder 1, 
then in the app folder you also need to make folder 1 and put the file in it.
*/ ?><?php
/**
 * Magento Enterprise Edition
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Magento Enterprise Edition End User License Agreement
 * that is bundled with this package in the file LICENSE_EE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://www.magento.com/license/enterprise-edition
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magento.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magento.com for more information.
 *
 * @category    design
 * @package     default_default
 * @copyright Copyright (c) 2006-2015 X.commerce, Inc. (http://www.magento.com)
 * @license http://www.magento.com/license/enterprise-edition
 */
?>
<?php $_storeId = $this->getRequest()->getParam('store'); ?>
<?php if ($this->isReadonly()):?>
<?php $_readonly = ' disabled="disabled" ';?>
<?php else: ?>
<?php $_readonly = '';?>
<?php endif; ?>
<div class="entry-edit">
    <div class="entry-edit-head">
        <h4 class="icon-head head-edit-form fieldset-legend"><?php echo Mage::helper('catalog')->__('Inventory') ?></h4>
    </div>
    <fieldset>

        <legend><?php echo Mage::helper('catalog')->__('Inventory') ?></legend>
        <table cellspacing="0" class="form-list" id="table_cataloginventory">

<?php /* START AITOC CODE */ ?>

<?php if (!$this->IsNew() AND !$this->isDefaultWebsite()) { ?>

        <tr style="display:none">
            <td class="label"><label for="inventory_use_default_website_stock"><?php echo Mage::helper('catalog')->__('Website Inventory') ?></label></td>
            <td class="value">

            <?php $_checked = ($this->getFieldValue('use_default_website_stock') || $this->IsNew()) ? 'checked="checked"' : '' ?>
            <input type="hidden" name="<?php echo $this->getFieldSuffix() ?>[stock_data][use_default_website_stock]" value="0" />

            <input type="checkbox" id="inventory_use_default_website_stock" name="<?php echo $this->getFieldSuffix() ?>[stock_data][use_default_website_stock]" value="0"   onclick="changeDefaultWebsiteStockOption();" class="checkbox" <?php echo $_readonly;?>/>
            <label for="inventory_use_default_website_stock" class="normal"><?php echo Mage::helper('catalog')->__('Use Default Values') ?></label>

            <td class="value scope-label"><?php echo Mage::helper('catalog')->__('[WEBSITE]') ?></td>
        </tr>

        <tr>
            <td class="label" colspan="3"><br></td>
        </tr>

<?php } ?>

<?php /* FINISH AITOC CODE */ ?>

        <tr style="display:none">
            <td class="label"><label for="inventory_manage_stock"><?php echo Mage::helper('catalog')->__('Manage Stock') ?></label></td>
            <td class="value"><select id="inventory_manage_stock" name="<?php echo $this->getFieldSuffix() ?>[stock_data][manage_stock]" class="select" <?php echo $_readonly;?>>
                <option value="1" selected="selected"><?php echo Mage::helper('catalog')->__('Yes') ?></option>
                <!-- <option value="0"<?php if ($this->getConfigFieldValue('manage_stock') == 0): ?> selected="selected"<?php endif; ?>><?php echo Mage::helper('catalog')->__('No') ?></option> -->
            </select>
            <input type="hidden" id="inventory_manage_stock_default" value="<?php echo $this->getDefaultConfigValue('manage_stock'); ?>" />

            <?php $_checked = ($this->getFieldValue('use_config_manage_stock') || $this->IsNew()) ? 'checked="checked"' : '' ?>
            <input type="checkbox" id="inventory_use_config_manage_stock" name="<?php echo $this->getFieldSuffix() ?>[stock_data][use_config_manage_stock]" value="1" <?php echo $_checked ?> onclick="toggleValueElements(this, this.parentNode);" class="checkbox" <?php echo $_readonly;?>/>
            <label for="inventory_use_config_manage_stock" class="normal"><?php echo Mage::helper('catalog')->__('Use Config Settings') ?></label>
            <?php if (!$this->isReadonly()):?><script type="text/javascript">toggleValueElements($('inventory_use_config_manage_stock'), $('inventory_use_config_manage_stock').parentNode);</script><?php endif; ?></td>
            <?php /* START AITOC COMMENTING
            <td class="value scope-label"><?php echo Mage::helper('adminhtml')->__('[GLOBAL]') ?></td>
            FINISH AITOC COMMENTING */ ?>
            <td class="value scope-label"><?php echo Mage::helper('catalog')->__('[WEBSITE]') ?></td>
        </tr>

<?php if(!$this->getProduct()->isComposite()): ?>
        <?php
            if($_storeId)
            {
                $qty = $this->getFieldValue('qty')*1;
            }
            else
            {
                $qty = 0;
            }
        ?>
        <tr>
            <td class="label"><label for="inventory_qty"><?php echo Mage::helper('catalog')->__('数量初始值') ?><span class="required">*</span></label></td>
            <td class="value">
                <?php if (!$_readonly):?>
                <input type="hidden" id="original_inventory_qty" name="<?php echo $this->getFieldSuffix() ?>[stock_data][original_inventory_qty]" value="<?php echo $qty; ?>"/>
                <?php endif;?>
                <input disabled="true" type="text" class="input-text required-entry validate-number" id="inventory_qty" name="<?php echo $this->getFieldSuffix() ?>[stock_data][qty]" value="<?php echo $qty; ?>" <?php echo $_readonly;?>/>
            </td>
            <?php /* START AITOC COMMENTING
            <td class="value scope-label"><?php echo Mage::helper('adminhtml')->__('[GLOBAL]') ?></td>
            FINISH AITOC COMMENTING */ ?>
            <td class="value scope-label"><?php echo Mage::helper('catalog')->__('[WEBSITE]') ?></td>
        </tr>

        <tr>
            <td class="label"><label for="inventory_min_qty"><?php echo Mage::helper('catalog')->__('Qty for Item\'s Status to Become Out of Stock') ?></label></td>
            <td class="value"><input type="text" class="input-text validate-number" id="inventory_min_qty" name="<?php echo $this->getFieldSuffix() ?>[stock_data][min_qty]" value="<?php echo $this->getFieldValue('min_qty')*1 ?>" <?php echo $_readonly;?>/>

            <?php $_checked = ($this->getFieldValue('use_config_min_qty') || $this->IsNew()) ? 'checked="checked"' : '' ?>
            <input type="checkbox" id="inventory_use_config_min_qty" name="<?php echo $this->getFieldSuffix() ?>[stock_data][use_config_min_qty]" value="1" <?php echo $_checked ?> onclick="toggleValueElements(this, this.parentNode);" <?php echo $_readonly;?> />
            <label for="inventory_use_config_min_qty" class="normal"><?php echo Mage::helper('catalog')->__('Use Config Settings') ?></label>
            <?php if (!$this->isReadonly()):?><script type="text/javascript">toggleValueElements($('inventory_use_config_min_qty'), $('inventory_use_config_min_qty').parentNode);</script><?php endif; ?></td>
            <?php /* START AITOC COMMENTING
            <td class="value scope-label"><?php echo Mage::helper('adminhtml')->__('[GLOBAL]') ?></td>
            FINISH AITOC COMMENTING */ ?>
            <td class="value scope-label"><?php echo Mage::helper('catalog')->__('[WEBSITE]') ?></td>
        </tr>

        <tr>
            <td class="label"><label for="inventory_min_sale_qty"><?php echo Mage::helper('catalog')->__('Minimum Qty Allowed in Shopping Cart') ?></label></td>
            <td class="value"><input type="text" class="input-text validate-number" id="inventory_min_sale_qty" name="<?php echo $this->getFieldSuffix() ?>[stock_data][min_sale_qty]" value="<?php echo $this->getFieldValue('min_sale_qty')*1 ?>" <?php echo $_readonly;?>/>

            <?php $_checked = ($this->getFieldValue('use_config_min_sale_qty') || $this->IsNew()) ? 'checked="checked"' : '' ?>
            <input type="checkbox" id="inventory_use_config_min_sale_qty" name="<?php echo $this->getFieldSuffix() ?>[stock_data][use_config_min_sale_qty]" value="1" <?php echo $_checked ?> onclick="toggleValueElements(this, this.parentNode);" class="checkbox" <?php echo $_readonly;?> />
            <label for="inventory_use_config_min_sale_qty" class="normal"><?php echo Mage::helper('catalog')->__('Use Config Settings') ?></label>
            <?php if (!$this->isReadonly()):?><script type="text/javascript">toggleValueElements($('inventory_use_config_min_sale_qty'), $('inventory_use_config_min_sale_qty').parentNode);</script><?php endif; ?></td>
            <?php /* START AITOC COMMENTING
            <td class="value scope-label"><?php echo Mage::helper('adminhtml')->__('[GLOBAL]') ?></td>
            FINISH AITOC COMMENTING */ ?>
            <td class="value scope-label"><?php echo Mage::helper('catalog')->__('[WEBSITE]') ?></td>
        </tr>

        <tr>
            <td class="label"><label for="inventory_max_sale_qty"><?php echo Mage::helper('catalog')->__('Maximum Qty Allowed in Shopping Cart') ?></label></td>
            <td class="value"><input type="text" class="input-text validate-number" id="inventory_max_sale_qty" name="<?php echo $this->getFieldSuffix() ?>[stock_data][max_sale_qty]" value="<?php echo $this->getFieldValue('max_sale_qty')*1 ?>" <?php echo $_readonly;?> />

            <?php $_checked = ($this->getFieldValue('use_config_max_sale_qty') || $this->IsNew()) ? 'checked="checked"' : '' ?>
            <input type="checkbox" id="inventory_use_config_max_sale_qty" name="<?php echo $this->getFieldSuffix() ?>[stock_data][use_config_max_sale_qty]" value="1" <?php echo $_checked ?> onclick="toggleValueElements(this, this.parentNode);" class="checkbox" <?php echo $_readonly;?> />
            <label for="inventory_use_config_max_sale_qty" class="normal"><?php echo Mage::helper('catalog')->__('Use Config Settings') ?></label>
            <?php if (!$this->isReadonly()):?><script type="text/javascript">toggleValueElements($('inventory_use_config_max_sale_qty'), $('inventory_use_config_max_sale_qty').parentNode);</script><?php endif; ?></td>
            <?php /* START AITOC COMMENTING
            <td class="value scope-label"><?php echo Mage::helper('adminhtml')->__('[GLOBAL]') ?></td>
            FINISH AITOC COMMENTING */ ?>
            <td class="value scope-label"><?php echo Mage::helper('catalog')->__('[WEBSITE]') ?></td>
        </tr>

        <?php if($this->canUseQtyDecimals()): ?>
        <tr>
            <td class="label"><label for="inventory_is_qty_decimal"><?php echo Mage::helper('catalog')->__('Qty Uses Decimals') ?></label></td>
            <td class="value"><select id="inventory_is_qty_decimal" name="<?php echo $this->getFieldSuffix() ?>[stock_data][is_qty_decimal]" class="select" <?php echo $_readonly;?>>
                <option value="0"><?php echo Mage::helper('catalog')->__('No') ?></option>
                <option value="1"<?php if($this->getFieldValue('is_qty_decimal')==1): ?> selected="selected"<?php endif; ?>><?php echo Mage::helper('catalog')->__('Yes') ?></option>
            </select>
            </td>
            <?php /* START AITOC COMMENTING
            <td class="value scope-label"><?php echo Mage::helper('adminhtml')->__('[GLOBAL]') ?></td>
            FINISH AITOC COMMENTING */ ?>
            <td class="value scope-label"><?php echo Mage::helper('catalog')->__('[WEBSITE]') ?></td>
        </tr>

        <?php if (!$this->isVirtual()) : ?>
        <tr>
            <td class="label"><label for="inventory_is_decimal_divided"><?php echo Mage::helper('catalog')->__('Can be Divided into Multiple Boxes for Shipping') ?></label></td>
            <td class="value"><select id="inventory_is_decimal_divided" name="<?php echo $this->getFieldSuffix() ?>[stock_data][is_decimal_divided]" class="select" <?php echo $_readonly;?>>
                <option value="0"><?php echo Mage::helper('catalog')->__('No') ?></option>
                <option value="1"<?php if($this->getFieldValue('is_decimal_divided') == 1): ?> selected="selected"<?php endif; ?>><?php echo Mage::helper('catalog')->__('Yes') ?></option>
            </select>
            </td>
            <?php /* START AITOC COMMENTING
            <td class="value scope-label"><?php echo Mage::helper('adminhtml')->__('[GLOBAL]') ?></td>
            FINISH AITOC COMMENTING */ ?>
            <td class="value scope-label"><?php echo Mage::helper('catalog')->__('[WEBSITE]') ?></td>
        </tr>
        <?php endif; ?>

        <?php endif; ?>

        <tr>
            <td class="label"><label for="inventory_backorders"><?php echo Mage::helper('catalog')->__('Backorders') ?></label></td>
            <td class="value"><select id="inventory_backorders" name="<?php echo $this->getFieldSuffix() ?>[stock_data][backorders]" class="select" <?php echo $_readonly;?>>
            <?php foreach ($this->getBackordersOption() as $option): ?>
                <?php $_selected = ($option['value'] == $this->getFieldValue('backorders')) ? 'selected="selected"' : '' ?>
                <option value="<?php echo $option['value'] ?>" <?php echo $_selected ?>><?php echo $option['label'] ?></option>
            <?php endforeach; ?>
            </select>

            <?php $_checked = ($this->getFieldValue('use_config_backorders') || $this->IsNew()) ? 'checked="checked"' : '' ?>
            <input type="checkbox" id="inventory_use_config_backorders" name="<?php echo $this->getFieldSuffix() ?>[stock_data][use_config_backorders]" value="1" <?php echo $_checked ?> onclick="toggleValueElements(this, this.parentNode);" class="checkbox" <?php echo $_readonly;?> />
            <label for="inventory_use_config_backorders" class="normal"><?php echo Mage::helper('catalog')->__('Use Config Settings') ?></label>
            <?php if (!$this->isReadonly()):?><script type="text/javascript">toggleValueElements($('inventory_use_config_backorders'), $('inventory_use_config_backorders').parentNode);</script><?php endif; ?></td>
            <?php /* START AITOC COMMENTING
            <td class="value scope-label"><?php echo Mage::helper('adminhtml')->__('[GLOBAL]') ?></td>
            FINISH AITOC COMMENTING */ ?>
            <td class="value scope-label"><?php echo Mage::helper('catalog')->__('[WEBSITE]') ?></td>
        </tr>
        <tr>
            <td class="label"><label for="inventory_notify_stock_qty"><?php echo Mage::helper('catalog')->__('Notify for Quantity Below') ?></label></td>
            <td class="value"><input type="text" class="input-text validate-number" id="inventory_notify_stock_qty" name="<?php echo $this->getFieldSuffix() ?>[stock_data][notify_stock_qty]" value="<?php echo $this->getFieldValue('notify_stock_qty')*1 ?>" <?php echo $_readonly;?>/>

            <?php $_checked = ($this->getFieldValue('use_config_notify_stock_qty') || $this->IsNew()) ? 'checked="checked"' : '' ?>
            <input type="checkbox" id="inventory_use_config_notify_stock_qty" name="<?php echo $this->getFieldSuffix() ?>[stock_data][use_config_notify_stock_qty]" value="1" <?php echo $_checked ?> onclick="toggleValueElements(this, this.parentNode);" class="checkbox" <?php echo $_readonly;?>/>
            <label for="inventory_use_config_notify_stock_qty" class="normal"><?php echo Mage::helper('catalog')->__('Use Config Settings') ?></label>
            <?php if (!$this->isReadonly()):?><script type="text/javascript">toggleValueElements($('inventory_use_config_notify_stock_qty'), $('inventory_use_config_notify_stock_qty').parentNode);</script><?php endif; ?></td>
            <?php /* START AITOC COMMENTING
            <td class="value scope-label"><?php echo Mage::helper('adminhtml')->__('[GLOBAL]') ?></td>
            FINISH AITOC COMMENTING */ ?>
            <td class="value scope-label"><?php echo Mage::helper('catalog')->__('[WEBSITE]') ?></td>
        </tr>
<?php endif; ?>
        <tr>
            <td class="label"><label for="inventory_enable_qty_increments"><?php echo Mage::helper('catalog')->__('Enable Qty Increments') ?></label></td>
            <td class="value"><select id="inventory_enable_qty_increments" name="<?php echo $this->getFieldSuffix() ?>[stock_data][enable_qty_increments]" class="select" <?php echo $_readonly;?>>
                <option value="1"><?php echo Mage::helper('catalog')->__('Yes') ?></option>
                <option value="0"<?php if ($this->getConfigFieldValue('enable_qty_increments') == 0): ?> selected="selected"<?php endif; ?>><?php echo Mage::helper('catalog')->__('No') ?></option>
            </select>
            <input type="hidden" id="inventory_enable_qty_increments_default" value="<?php echo $this->getDefaultConfigValue('enable_qty_increments'); ?>" />

            <?php $_checked = ($this->getFieldValue('use_config_enable_qty_increments') || $this->IsNew()) ? 'checked="checked"' : '' ?>
            <input type="checkbox" id="inventory_use_config_enable_qty_increments" name="<?php echo $this->getFieldSuffix() ?>[stock_data][use_config_enable_qty_increments]" value="1" <?php echo $_checked ?> onclick="toggleValueElements(this, this.parentNode);" class="checkbox" <?php echo $_readonly;?>/>
            <label for="inventory_use_config_enable_qty_increments" class="normal"><?php echo Mage::helper('catalog')->__('Use Config Settings') ?></label>
            <?php if (!$this->isReadonly()):?><script type="text/javascript">toggleValueElements($('inventory_use_config_enable_qty_increments'), $('inventory_use_config_enable_qty_increments').parentNode);</script><?php endif; ?></td>
            <?php /* START AITOC COMMENTING
            <td class="value scope-label"><?php echo Mage::helper('adminhtml')->__('[GLOBAL]') ?></td>
            FINISH AITOC COMMENTING */ ?>
            <td class="value scope-label"><?php echo Mage::helper('catalog')->__('[WEBSITE]') ?></td>
        </tr>
        <tr>
            <td class="label"><label for="inventory_qty_increments"><?php echo Mage::helper('catalog')->__('Qty Increments') ?></label></td>
            <td class="value">
                <input type="text" class="input-text validate-digits" id="inventory_qty_increments" name="<?php echo $this->getFieldSuffix() ?>[stock_data][qty_increments]" value="<?php echo $this->getFieldValue('qty_increments')*1 ?>" <?php echo $_readonly;?>/>
                <?php $_checked = ($this->getFieldValue('use_config_qty_increments') || $this->IsNew()) ? 'checked="checked"' : '' ?>
                <input type="checkbox" id="inventory_use_config_qty_increments" name="<?php echo $this->getFieldSuffix() ?>[stock_data][use_config_qty_increments]" value="1" <?php echo $_checked ?> onclick="toggleValueElements(this, this.parentNode);" class="checkbox" <?php echo $_readonly;?>/>
                <label for="inventory_use_config_qty_increments" class="normal"><?php echo Mage::helper('catalog')->__('Use Config Settings') ?></label>
                <?php if (!$this->isReadonly()):?><script type="text/javascript">toggleValueElements($('inventory_use_config_qty_increments'), $('inventory_use_config_qty_increments').parentNode);</script><?php endif; ?></td>
            <?php /* START AITOC COMMENTING
            <td class="value scope-label"><?php echo Mage::helper('adminhtml')->__('[GLOBAL]') ?></td>
            FINISH AITOC COMMENTING */ ?>
            <td class="value scope-label"><?php echo Mage::helper('catalog')->__('[WEBSITE]') ?></td>
        </tr>
        <tr>
            <td class="label"><label for="inventory_stock_availability"><?php echo Mage::helper('catalog')->__('Stock Availability') ?></label></td>
            <td class="value">
            <?php if($_storeId):?>
                <select id="inventory_stock_availability" name="<?php echo $this->getFieldSuffix() ?>[stock_data][is_in_stock]" class="select" <?php echo $_readonly;?>>
                <?php foreach ($this->getStockOption() as $option): ?>
                    <?php $_selected = ($option['value'] == $this->getFieldValue('is_in_stock')) ? 'selected="selected"' : '' ?>
                    <option value="<?php echo $option['value'] ?>" <?php echo $_selected ?>><?php echo $option['label'] ?></option>
                <?php endforeach; ?>
                </select>
            <?php else:?>
                <select id="inventory_stock_availability" name="<?php echo $this->getFieldSuffix() ?>[stock_data][is_in_stock]" class="select" <?php echo $_readonly;?>>
                <?php foreach ($this->getStockOption() as $option): ?>
                    <option value="1" selected="selected">有货</option>
                <?php endforeach; ?>
                </select>
            <?php endif;?>
            </td>
           <?php /* START AITOC COMMENTING
            <td class="value scope-label"><?php echo Mage::helper('adminhtml')->__('[GLOBAL]') ?></td>
            FINISH AITOC COMMENTING */ ?>
            <td class="value scope-label"><?php echo Mage::helper('catalog')->__('[WEBSITE]') ?></td>
        </tr>
        </table>
    </fieldset>
</div>
<script type="text/javascript">
//<![CDATA[
    function changeManageStockOption()
    {
        var manageStock = $('inventory_use_config_manage_stock').checked
            ? $('inventory_manage_stock_default').value
            : $('inventory_manage_stock').value;
        var catalogInventoryNotManageStockFields = {
            inventory_min_sale_qty: true,
            inventory_max_sale_qty: true,
            inventory_enable_qty_increments : true,
            inventory_qty_increments: true
            ,inventory_use_default_website_stock: true
        };

        $$('#table_cataloginventory tr').each(function(el) {
            if (el == $('inventory_manage_stock').up(1)) {
                return;
            }

            for (field in catalogInventoryNotManageStockFields) {
                if ($(field) && ($(field).up(1) == el)) {
                    return;
                }
            }

            el[manageStock == 1 ? 'show' : 'hide']();
        });

        return true;
    }

    function applyEnableQtyIncrements() {
        var enableQtyIncrements = $('inventory_use_config_enable_qty_increments').checked
            ? $('inventory_enable_qty_increments_default').value
            : $('inventory_enable_qty_increments').value;

        $('inventory_qty_increments').up('tr')[enableQtyIncrements == 1 ? 'show' : 'hide']();
    }

    function applyEnableDecimalDivided() {
    <?php if (!$this->isVirtual()) : ?>
        $('inventory_is_decimal_divided').up('tr').hide();
        <?php endif; ?>
        $('inventory_qty_increments').removeClassName('validate-digits').removeClassName('validate-number');
        $('inventory_min_sale_qty').removeClassName('validate-digits').removeClassName('validate-number');
        if ($('inventory_is_qty_decimal').value == 1) {
        <?php if (!$this->isVirtual()) : ?>
            $('inventory_is_decimal_divided').up('tr').show();
            <?php endif; ?>
            $('inventory_qty_increments').addClassName('validate-number');
            $('inventory_min_sale_qty').addClassName('validate-number');
        } else {
            $('inventory_qty_increments').addClassName('validate-digits');
            $('inventory_min_sale_qty').addClassName('validate-digits');
        }
    }

    Event.observe(window, 'load', function() {
        if ($('inventory_manage_stock') && $('inventory_use_config_manage_stock')) {
            Event.observe($('inventory_manage_stock'), 'change', changeManageStockOption);
            Event.observe($('inventory_use_config_manage_stock'), 'change', changeManageStockOption);
            changeManageStockOption();
        }
        if ($('inventory_enable_qty_increments') && $('inventory_use_config_enable_qty_increments')) {
            Event.observe($('inventory_enable_qty_increments'), 'change', applyEnableQtyIncrements);
            Event.observe($('inventory_use_config_enable_qty_increments'), 'change', applyEnableQtyIncrements);
            applyEnableQtyIncrements();
        }
        if ($('inventory_is_qty_decimal') && $('inventory_qty_increments') && $('inventory_min_sale_qty')) {
            Event.observe($('inventory_is_qty_decimal'), 'change', applyEnableDecimalDivided);
            applyEnableDecimalDivided();
        }
    });

    <?php /* START AITOC CODE */ ?>

    <?php if (!$this->IsNew() AND !$this->isDefaultWebsite()) { ?>

    function changeDefaultWebsiteStockOption()
    {
        $$('#table_cataloginventory tr').each(manageAitocStockEach);

        return true;
    }

    function manageAitocStockEach(el)
    {
        var catalogInventoryNotManagestockFields = {
            inventory_min_sale_qty: true,
            inventory_max_sale_qty: true,
            inventory_enable_qty_increments : true,
            inventory_qty_increments: true,
            inventory_use_default_website_stock: true
        };

        if ($('inventory_use_default_website_stock').checked) {
            var manageStock = 0;
        }
        else {
            var manageStock = 1;

            if ($('inventory_use_config_manage_stock').checked) {
                manageStock = $('inventory_manage_stock_default').value;
            }
            else {
                manageStock = $('inventory_manage_stock').value;
            }

            if (el == $('inventory_manage_stock').up(1)) {
                manageStock = 1;
            }

            for(field in catalogInventoryNotManagestockFields) {
                if ($(field) && ($(field).up(1) == el)) {
                    manageStock = 1;
                }
            }

        }
        if ($("inventory_use_default_website_stock") && el == $('inventory_use_default_website_stock').up(1)) {
            return;
        }

        if (manageStock == 1) {
            el.show();
        }
        else {
            el.hide();
        }
        return;
    }

    Event.observe(window, 'load', changeDefaultWebsiteStockOption);

    <?php } ?>

    <?php /* FINISH AITOC CODE */ ?>

//]]>
</script>
